#include <iostream>
#include <any>
#include <vector>

using namespace std;

class Test
{
public:
    Test()
    {

    }

    Test(int num, string name) : m_num(num), m_name(name)
    {

    }

    Test(const std::initializer_list<any> &li)
    {

    }

    ~Test()
    {

    }
public:
    int m_num;
    string m_name;
};

void test(std::any &a)
{

}

void func(const std::initializer_list<any> &li)
{
    for(auto it = li.begin(); it != li.end(); ++it)
    {
        if(it->type() == typeid(int))
        {
            cout << "int:" << std::any_cast<int>(*it) << endl;
        }
        else if(it->type() == typeid(string))
        {
            cout << "string:" << std::any_cast<const string &>(*it) << endl;
        }
        else if(it->type() == typeid(const char *))
        {
            cout << "string:" << std::any_cast<const char *>(*it) << endl;
        }
    }

    cout << "\n";
}

int main(int argc, char **argv)
{
    //{} ---initializer_list:类型检查

    int num = 3.3;
    //int num2 = {3.3};


    func({1,2,3,4,5,6});
    func({1,2,3});
    func({1,2});
    func({1,"zhangsan"});

    vector<int> vi{1,2,3,4,5,6};
    vector<int> vi2 = {1,2,3,4,5,6,7,8};
    
    Test t{1,"string"}; //必须存在有参全构造
    Test t1 = {1,"zhangsan"};//必须含有initializer_list作形参的构造函数

    cout << t.m_name << endl;
    cout << t.m_num << endl;

    any as = "string";
    any atest = Test(1,"zhangsan");

    return 0;
}